const { lessorsModel } = require('./models/lessorsModel');
module.exports.getLessors = async function(query) {
    const { pageSize, currentPage, _id, freezeState, searchData, input, value } = query;
    if (_id) {
        await lessorsModel.updateOne({ _id }, { state: freezeState });
    }
    if (input == undefined && value == undefined) {
        const data = await lessorsModel.find().limit(pageSize - '0').skip((currentPage - 1) * pageSize);
        const total = await lessorsModel.countDocuments();
        return { data, total };
    } else {
        // 先精准查询后模糊查询
        console.log(input, value);
        const data = await lessorsModel.find({ state: `${value}` }).limit(pageSize - '0').skip((currentPage - 1) * pageSize);
        const total = data.length;
        return { data, total };
    }

}